/**
 * Container,抽象类
 */
function Container(){
    this.children = [];
}
Container.prototype = new DisplayObject();

Container.prototype.addChild = function(child){
    this.children.push(child);
}
//Adds a child DisplayObject instance to the specific index of this DisplayObjectContainer instance.
Container.prototype.addChildAt = function(child, index){
    //TODO
}
Container.prototype.getChildAt = function(index){
    return this.children[index];
}
Container.prototype.getChildByName = function(name){
    for(var i = 0; i < this.children.length; i++){
        if(this.children[i].name === name){
            return this.children[i];
        }
    }
    return null;
}
//Returns the index position of a child DisplayObject instance.
Container.prototype.getChildIndex = function(child){
    //TODO
}
//Returns the number of children of this object.
Container.prototype.getNumChildren = function(){
    return this.children.length;
}
Container.prototype.removeAllChildren = function(){
    this.children = [];
}
//Removes the specified child DisplayObject instance from the child list of the DisplayObjectContainer instance.
Container.prototype.removeChild = function(child){
    for(var i = 0; i < this.children.length; i++){
        if(this.children[i] === child){
            this.children.splice(i, 1);
            break;
        }
    }
    return this.children;
}
Container.prototype.removeChildAt = function(index){
    this.children.splice(index, 1);
    return this.children;
}
//Note: will delete all children that have the same name
Container.prototype.removeChildByName = function(name){
    for(var i = 0; i < this.children.length; i++){
        if(this.children[i].name === name){
            this.children.splice(i, 1);
        }
    }
    return this.children;
}